package com.demo.rabbitmq.controller;

import com.demo.rabbitmq.producer.DirectProducer;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通过请求触发发送消息，验证traceId能否从生产者传递到消费者，通过观察日志的打印的traceId
 */
@Slf4j
@RestController
public class SendMsgController {

    @Resource
    private DirectProducer directProducer;

    @GetMapping("send")
    public void send() {
        long currentTimeMillis = System.currentTimeMillis();
        log.info("当前时间戳：" + currentTimeMillis);
        directProducer.send((int) currentTimeMillis);
    }
}
